﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using LibParasInject;

namespace ParasInjectGUI
{
    public partial class FrmProject : Form
    {
        public FrmProject()
        {
            InitializeComponent();
        }

        void btnSearchBinsDir_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dirDialog = new FolderBrowserDialog();
            dirDialog.ShowNewFolderButton = false;
            dirDialog.Description = "Carpeta de binarios para parasitar..";
            if (Directory.Exists(txtBinsDir.Text))
                dirDialog.SelectedPath = txtBinsDir.Text;                
            DialogResult result = dirDialog.ShowDialog();
            if (result == DialogResult.OK) {
                txtBinsDir.Text = dirDialog.SelectedPath;
                lstBins.Items.Clear();
                foreach (string sFile in Directory.GetFiles(dirDialog.SelectedPath))
                    if (Injector.isValidAssembly(sFile))
                        lstBins.Items.Add(Path.GetFileName(sFile));
                txtOutputDir.Text = txtBinsDir.Text + Path.DirectorySeparatorChar + "ParasiOut";
            }
        }

        private void btnSearchOutputDir_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dirDialog = new FolderBrowserDialog();
            dirDialog.Description = "Carpeta de salida";
            if (Directory.Exists(txtOutputDir.Text))
                dirDialog.SelectedPath = txtOutputDir.Text;
            DialogResult result = dirDialog.ShowDialog();
            if (result == DialogResult.OK)
                txtOutputDir.Text = dirDialog.SelectedPath;
        }
    }
}
